import Mapper from './_mapper'

export const reputationMap = new (class ReputationMap extends Mapper<{
  name: string
  color: string
}> {
  // 存在顺序，上面优先级高于下面
  protected enums = {
    '3-': {
      name: '新店',
      color: '#2dc4b1'
    },
    '1-': {
      name: '品牌',
      color: '#ffa60b'
    },
    '2-': {
      name: '优选',
      color: '#df9e1d'
    }
  }
})()

export const businessStatusMapper = new (class BusinessStatusMapper extends Mapper<{
  name: string
  color: string
}> {
  protected enums = {
    '1': {
      name: '营业中',
      color: '#41b883'
    },
    '0': {
      name: '休息中',
      color: '#464646'
    }
  }
})()

export const platformDeliveryMapper = new (class PlatformDeliveryMapper extends Mapper<{
  name: string
  style: string
}> {
  protected enums = {
    '1': {
      name: '平台配送',
      style: 'border: none;color: black;background-color: #ffd930;'
    },
    '2': {
      name: '商家自配',
      style: ''
    }
  }
})()
class ReceivingMethodOption {
  name: string
  value: string
  constructor(name: string, value: string) {
    this.name = name
    this.value = value
  }
  equals(inValue: string | undefined) {
    return inValue != undefined && this.value === inValue
  }
}
export class ReceivingMethod extends Mapper<string> {
  public static DELIVERY = new ReceivingMethodOption('配送', '1')
  public static SHOP_EAT = new ReceivingMethodOption('店食', '2')
  public static SELF_PICKUP = new ReceivingMethodOption('自提', '3')
  protected enums = {
    '1': '配送',
    '2': '店食',
    '3': '自提'
  }
}
export const receivingMethodMapper = new ReceivingMethod()

export class OrderState extends Mapper<{
  name: string
  tis: string
}> {
  public static readonly WAITING_FOR_PAYMENT = 1 // 1：待支付
  public static readonly WAITING_FOR_ACCEPTANCE = 2 // 2：待接单
  public static readonly ORDER_ACCEPTED = 3 // 已接单
  public static readonly PRODUCTION_COMPLETED = 4 // 制作完成
  public static readonly IN_DELIVERY = 5 // 配送中
  public static readonly ORDER_COMPLETED = 6 // 已完成
  public static readonly APPLY_FOR_AFTER_SALE = 7 // 申请售后
  public static readonly ORDER_CANCELED = 8 // 已取消
  protected enums = {
    '1': {
      name: '待支付',
      tis: '如需下单，请尽快支付'
    },
    '2': {
      name: '待接单',
      tis: '如长时间不接单可申请退单'
    },
    '3': {
      name: '已接单',
      tis: '商家已接单，请耐心等待'
    },
    '4': {
      name: '制作完成',
      tis: '餐食已制作完成'
    },
    '5': {
      name: '配送中',
      tis: '您的外卖配送中'
    },
    '6': {
      name: '已完成',
      tis: '订单已完成'
    },
    '7': {
      name: '售后中',
      tis: '正在申请退款,待商家审核'
    },
    '8': {
      name: '已取消',
      tis: '订单已取消'
    }
  }
}
export const orderStateMapper = new OrderState()

/**
 * 性别
 */
export class Sex {
  // 男
  public static MALE = 1
  // 女
  public static FEMALE = 0
}
export enum RiderWorkState {
  /**
   * 已上线
   */
  ONLINE = 1,

  /**
   * 已下线
   */
  OFFLINE = 0
}
/**
 * 配送订单状态
 */
export enum DeliveryOrderState {
  PENDING_PICKUP = 1, // 待骑手接单
  RIDER_RECEIVED_ORDER = 2, // 骑手已接单
  RIDER_ARRIVED_STORE = 3, // 骑手已到店
  RIDER_PICKED_UP = 4, // 骑手已取单
  DELIVERED_TO_USER = 5 // 已交付给用户
}
